package U4;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Test3 {
	public static void main1(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int num = sc.nextInt();
			List<Integer> list = new ArrayList<Integer>();
			for(int i = 0;i <= num;++ i) {
				list.add(i);
			}
			while(list.size() > 1) {
				for(int i = 0;i < list.size();i ++) {
					list.remove(i);
				}
			}
			System.out.println(list.get(0));
		}
		
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int num = sc.nextInt();
			int num1 = 1;
			while(num1 < num) {
				num1 = num1 << 1;
			}
			num1 = (num1 >> 1) - 1;
			System.out.println(num1);
		}
		
	}

}
